import {fromJS} from 'immutable'
import {actionTypes} from './index'
import * as constant from '@/config/constant'

const defaultState = fromJS({
    wanCount:1,
    visible: false,
    confirmLoading: false,
    modalText: constant.OPERATION_CALL_REBOOT,
    modalTitle: constant.PLEASE_CHECK,
    progressVisible: false,
    progressPercent: 0,
    progressAction: 'active'
})


export default (state = defaultState, action)=>{
    switch(action.type){
        case actionTypes.UPDATE_DATA:
            return state.merge(action.value)
        case actionTypes.CHANGE_MODAL_STATUS:
            return state.merge(action.value)
        case actionTypes.CHANGE_PROGRESS_PERCENT:
            return state.set('progressPercent',state.get('progressPercent')+1)
        case actionTypes.RESET_MODAL_STATUS:
            return state.merge(action.value)
        default:
            return state
    }
}
